package com.wxzz.elearning.common.bean;

import com.wxzz.elearning.common.constants.RabbitPool;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class OperationLogProducer {


    @Autowired
    private RabbitTemplate rabbitTemplate;

    public void ackMQSender(String msg) {
        //log.info("send ack message :" + msg);
        //消息消费者确认收到消息后，手动ack回执
        // 生产者发送消息到exchange后没有绑定的queue时将消息退回

        //发送 这里不设置routing_key,因为设置了也无效，发送端的routing_key写任何字符都会被忽略。
        this.rabbitTemplate.convertAndSend(RabbitPool.DEFAULT_QUEUE, msg);
    }

}
